<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        var fun = function (str) {
            var arr = []
            for (var i = 0; i < str.length; i++) {
                arr.push(str.charAt(i))

            }
            var arr2 = arr.reduce(function (pre, cur) {
                return (pre.indexOf(cur) === -1 ? pre.concat(cur) : pre)
            }, [])
            var str1 = arr2.join('')
            return str1
        }("aabbccdda")
        console.log(fun)
    </script>
</body>

</html>